////////////////////////////////////////////////////////////////////////////////
///																			 ///
///			Codes to generate all the main tables in this paper				 ///
///																			 ///
////////////////////////////////////////////////////////////////////////////////

** Set globals
global sim_730_prob_bins I_prob_em_bin_0 I_prob_em_bin_1 I_prob_em_bin_2 I_prob_em_bin_3 I_prob_em_bin_4 I_prob_em_bin_5 I_prob_em_bin_6 I_prob_em_bin_7 I_prob_em_bin_8 I_prob_em_bin_9 I_prob_em_bin_10 I_prob_em_bin_11

global demo_controls FirstGen female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T sat_combined ICitizen

*------------------------------------------------------------------------------*

**** Table 1: Summary Statistics - Sample Comparison ****


* Summary Statistics - Sample Comparison (Column 1 of Table 1)

* call the registrar data
use "${rawdata}Fall18end.dta" ,clear

append using "${rawdata}Fall19end.dta"
append using "${rawdata}Spring20end.dta"

* clean the data
keep if event == "TERMEND"

keep if inlist(studentclassificationboap,"01","02")

keep id academicperiod courseidentification 

* merge the data
merge m:1 id academicperiod using "${cleandata}all_freshmen.dta", nogen keep(1 3)

drop if sat_combined ==.

* Label demographic variables *
label variable female "Female"
label variable white "White"
label variable black "Black"
label variable hispanic "Hispanic"
label variable asian "Asian"
label variable other "Others"
label variable FirstGen "1st Gen Student"
label variable sat_combined "SAT Combined"
label variable ICitizen "Citizen"

* Overall student-course-term pair
eststo domestic: estpost sum female white black hispanic asian other FirstGen sat_combined ICitizen if inlist(academicperiod,201910,202010) 
esttab domestic using "${results}summary_statistics_all_freshmen.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label

/*

             |  e(count)   e(sum_w)    e(mean)     e(Var)      e(sd)     e(min)     e(max)     e(sum) 
-------------+----------------------------------------------------------------------------------------
      female |     71435      71435   .4512494   .2476268   .4976212          0          1      32235 
       white |     71435      71435   .6208301   .2354034   .4851839          0          1      44349 
       black |     71435      71435    .032813   .0317368   .1781482          0          1       2344 
    hispanic |     71435      71435   .0605306   .0568674   .2384689          0          1       4324 
       asian |     71435      71435   .0964373   .0871384   .2951921          0          1       6889 
       other |     71435      71435   .0585147   .0550915   .2347159          0          1       4180 
    FirstGen |     71435      71435   .1177854   .1039135   .3223561          0          1       8414 
sat_combined |     71435      71435   1283.489   22368.72   149.5618        660       1600   9.17e+07 
    ICitizen |     71435      71435   .8691258   .1137478   .3372651          0          1      62086 


*/



* Summary Statistics - Sample Comparison (Column 2 of Table 1)

*** Freshmen in batch (updated on 01/12/2026) - submission code Table 1

use "${cleandata}UniTime_MeetingTime_Fall2018.dta", clear

* append the data  
append using "${cleandata}UniTime_MeetingTime_Fall2019.dta"
append using "${cleandata}UniTime_MeetingTime_Spring2020.dta"

* merge the data
merge m:1 id Academic_Period using "${cleandata}all_freshmen.dta", nogen keep(3)

* drop missing sat scores
drop if sat_combined ==.

* save the data
save "${cleandata}UniTime_MeetingTime_Fall2018_Fall2019_Spring2020.dta", replace

* summary stat
eststo domestic: estpost sum female white black hispanic asian other FirstGen sat_combined ICitizen CourseRequestedCount if inlist(academicperiod,201910,202010) 
esttab domestic using "${results}summary_statistics_freshmen_in_batch.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label


/*

             |  e(count)   e(sum_w)    e(mean)     e(Var)      e(sd)     e(min)     e(max)     e(sum) 
-------------+----------------------------------------------------------------------------------------
      female |     52250      52250   .4784115   .2495387   .4995385          0          1      24997 
       white |     52250      52250   .6510813   .2271788   .4766327          0          1      34019 
       black |     52250      52250   .0283254   .0275236   .1659023          0          1       1480 
    hispanic |     52250      52250   .0599234   .0563337   .2373472          0          1       3131 
       asian |     52250      52250   .0927847   .0841773   .2901332          0          1       4848 
       other |     52250      52250   .0594833   .0559461   .2365292          0          1       3108 
    FirstGen |     52250      52250   .1161531   .1026635   .3204115          0          1       6069 
sat_combined |     52250      52250   1282.956   21224.97   145.6879        680       1600   6.70e+07 
    ICitizen |     52250      52250   .8915981   .0966528   .3108903          0          1      46586 
CourseRequ~t |     52250      52250    13.9929   19.71575   4.440242          1         48     731129 

*/




* Summary Statistics - Sample Comparison (Column 3 of Table 1)

*** Freshmen in batch (specific) - age 18 to 21, non-athlete, lower-level courses
use "${cleandata}UniTime_MeetingTime_Fall2018_Fall2019_Spring2020.dta",clear

* merge student classifications
merge m:1 id Academic_Period using "${cleandata}studuentclassification_201910_202010_202020.dta", keep(1 3) nogen

* keep true freshmen
keep if Classification =="01" | Classification =="02" 

* keep lower-level courses
keep if number <30000

* age 18 to 21
gen age = year - birthyear
keep if inlist(age,18,19,20,21)

*drop athlete students
merge m:1 id Academic_Period using "${cleandata}ICollegeAthlete.dta", keep(1 3) nogen
replace ICollegeAthlete = 0 if ICollegeAthlete==.
drop if ICollegeAthlete == 1


* summary stat
eststo domestic: estpost sum female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T FirstGen sat_combined ICitizen CourseRequestedCount
eststo domestic: estpost sum female white black hispanic asian other FirstGen sat_combined ICitizen CourseRequestedCount if inlist(academicperiod,201910,202010) 
esttab domestic using "${results}summary_statistics_freshmen_in_batch_specific.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label

/*

             |  e(count)   e(sum_w)    e(mean)     e(Var)      e(sd)     e(min)     e(max)     e(sum) 
-------------+----------------------------------------------------------------------------------------
      female |     50196      50196   .4768109   .2494672    .499467          0          1      23934 
       white |     50196      50196   .6547932   .2260436   .4754404          0          1      32868 
       black |     50196      50196   .0260379   .0253605   .1592497          0          1       1307 
    hispanic |     50196      50196   .0605228   .0568609   .2384552          0          1       3038 
       asian |     50196      50196   .0939716   .0851427   .2917922          0          1       4717 
       other |     50196      50196   .0589489   .0554751   .2355314          0          1       2959 
    FirstGen |     50196      50196   .1166826   .1030698   .3210449          0          1       5857 
sat_combined |     50196      50196   1283.631   21113.23   145.3039        680       1600   6.44e+07 
    ICitizen |     50196      50196   .8942744   .0945495   .3074891          0          1      44889 
CourseRequ~t |     50196      50196   14.00544   19.64067    4.43178          1         48     703017 


*/


* Summary Statistics - Sample Comparison (Column 4 of Table 1)
 /*
 
 See the code below: lines 72 to 96
 
 */

*------------------------------------------------------------------------------*

**** Table 1: Summary Statistics - Sample Comparison and 2: Summary Statistics - Student Demographics ****

* course grades
use "${cleandata}sample_course_grades_early_morning.dta",clear

** Summary statistics (main sample - Tables 1 and 2)
* Label demographic variables *
label variable female "Female"
label variable IWhite_T "White"
label variable IBlack_T "Black"
label variable IHispanic_T "Hispanic"
label variable IAsian_T "Asian"
label variable IOthers_T "Others"
label variable FirstGen "1st Gen Student"
label variable sat_combined "SAT Combined"
label variable ICitizen "Citizen"

* 7:30 AM student-course-stem pair (Column 1 of Table 2)
eststo domestic: estpost sum female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T FirstGen sat_combined ICitizen CourseRequestedCount prob_early_morning_sec if IAssignedBegin730 == 1
esttab domestic using "${results}summary_statistics_Course_Grade_730AM.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label

* Non-7:30 AM student-course-term pair (Column 2 of Table 2)
eststo domestic: estpost sum female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T FirstGen sat_combined ICitizen CourseRequestedCount prob_early_morning_sec if IAssignedBegin730 == 0
esttab domestic using "${results}summary_statistics_Course_Grade_Non730AM.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label


** Summary statistics Sample Comparison (Column 4 of Table 1)
* Overall student-course-term pair
eststo domestic: estpost sum female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T FirstGen sat_combined ICitizen CourseRequestedCount prob_early_morning_sec
esttab domestic using "${results}summary_statistics_Course_Grade_Overall.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label



**** Table A.1: Courses from Main Sample (Columns 1 and 2 of Table A.1) ****

tab course 

/*
      Course |      Freq.     Percent        Cum.
----------------+-----------------------------------
        AT10600 |         82        1.46        1.46
      BIOL11000 |      1,886       33.61       35.07
      BIOL11200 |          6        0.11       35.17
      BIOL20300 |        759       13.52       48.70
       COM11400 |         80        1.43       50.12
      ECON25200 |        152        2.71       52.83
      EDCI20500 |         24        0.43       53.26
      EDCI28500 |         10        0.18       53.44
      ENGL10600 |         20        0.36       53.80
        FR20100 |          8        0.14       53.94
        MA15800 |        774       13.79       67.73
        MA16010 |      1,451       25.86       93.59
        MA16020 |         72        1.28       94.87
      SPAN20100 |          6        0.11       94.98
      SPAN20200 |         12        0.21       95.19
      STAT11300 |        270        4.81      100.00
----------------+-----------------------------------
          Total |      5,612      100.00

*/

tab course if IAssignedBegin730 == 1
/*
        Course |      Freq.     Percent        Cum.
----------------+-----------------------------------
        AT10600 |         59        3.27        3.27
      BIOL11000 |        562       31.14       34.40
      BIOL11200 |          2        0.11       34.52
      BIOL20300 |        326       18.06       52.58
       COM11400 |         41        2.27       54.85
      ECON25200 |        148        8.20       63.05
      EDCI20500 |         17        0.94       63.99
      EDCI28500 |          8        0.44       64.43
      ENGL10600 |          8        0.44       64.88
        FR20100 |          2        0.11       64.99
        MA15800 |        158        8.75       73.74
        MA16010 |        232       12.85       86.59
        MA16020 |         29        1.61       88.20
      SPAN20100 |          5        0.28       88.48
      SPAN20200 |          5        0.28       88.75
      STAT11300 |        203       11.25      100.00
----------------+-----------------------------------
          Total |      1,805      100.00



*/




** Table 2: Columns 3 and 4 **

* Label demographic variables *
label variable female "Female"
label variable IWhite_T "White"
label variable IBlack_T "Black"
label variable IHispanic_T "Hispanic"
label variable IAsian_T "Asian"
label variable IOthers_T "Others"
label variable FirstGen "1st Gen Student"
label variable sat_combined "SAT Combined"
label variable ICitizen "Citizen"
label variable CourseRequestedCount "Requested Courses"

* 7:30 AM student-course-stem pair (Column 3 of Table 2)
eststo domestic: estpost sum female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T FirstGen sat_combined ICitizen CourseRequestedCount if corr_STEM_course_sample == 1 & IAssignedBegin730 == 1
esttab domestic using "${results}summary_statistics_correspondingSTEMcourses_730AM.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label

* Non-7:30 AM student-course-term pair (Column 4 of Table 2)
eststo domestic: estpost sum female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T FirstGen sat_combined ICitizen CourseRequestedCount if corr_STEM_course_sample == 1 & IAssignedBegin730 == 0
esttab domestic using "${results}summary_statistics_correspondingSTEMcourses_Non730AM.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label



**** Table A.1: Courses from Subsample - STEM Courses ****

tab course

/*

         Course |      Freq.     Percent        Cum.
----------------+-----------------------------------
        AT10600 |         45        1.29        1.29
      BIOL11000 |      1,233       35.38       36.67
      BIOL11200 |          6        0.17       36.84
      BIOL20300 |        503       14.43       51.28
      ECON25200 |         77        2.21       53.49
        MA15800 |        532       15.27       68.75
        MA16010 |        914       26.23       94.98
        MA16020 |         37        1.06       96.04
      STAT11300 |        138        3.96      100.00
----------------+-----------------------------------
          Total |      3,485      100.00


*/

tab course if IAssignedBegin730==1
/*
        Course |      Freq.     Percent        Cum.
----------------+-----------------------------------
        AT10600 |         33        3.03        3.03
      BIOL11000 |        383       35.14       38.17
      BIOL11200 |          2        0.18       38.35
      BIOL20300 |        201       18.44       56.79
      ECON25200 |         76        6.97       63.76
        MA15800 |        113       10.37       74.13
        MA16010 |        161       14.77       88.90
        MA16020 |         15        1.38       90.28
      STAT11300 |        106        9.72      100.00
----------------+-----------------------------------
          Total |      1,090      100.00


*/




**** Table 1: Columns 5 and 6 ****

* Label demographic variables *
label variable female "Female"
label variable IWhite_T "White"
label variable IBlack_T "Black"
label variable IHispanic_T "Hispanic"
label variable IAsian_T "Asian"
label variable IOthers_T "Others"
label variable FirstGen "1st Gen Student"
label variable sat_combined "SAT Combined"
label variable ICitizen "Citizen"
label variable CourseRequestedCount "Requested Courses"

* Overall 
estpost sum female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T FirstGen sat_combined ICitizen CourseRequestedCount if BroadDef_730_sample_F18 == 1 & IFall2018AssignedBegin730 == 1
esttab using "${results}summary_statistics_majorchoice_730am.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label

* Overall 
estpost sum female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T FirstGen sat_combined ICitizen CourseRequestedCount if BroadDef_730_sample_F18 == 1 & IFall2018AssignedBegin730 == 0
esttab using "${results}summary_statistics_majorchoice_non730am.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label


**** Table A.1: Courses from Subsample - Major ****

tab course if BroadDef_730_sample_F18 == 1
/*

         Course |      Freq.     Percent        Cum.
----------------+-----------------------------------
        AT10600 |         47        2.21        2.21
      BIOL11000 |        603       28.40       30.62
      BIOL20300 |        291       13.71       44.32
       COM11400 |         88        4.15       48.47
      ECON25200 |         85        4.00       52.47
      EDCI20500 |         28        1.32       53.79
      EDCI28500 |         11        0.52       54.31
      ENGL10600 |         37        1.74       56.05
        FR20100 |          9        0.42       56.48
        MA15800 |        241       11.35       67.83
        MA16010 |        485       22.85       90.67
        MA16020 |         38        1.79       92.46
      SPAN20200 |         16        0.75       93.22
      STAT11300 |        144        6.78      100.00
----------------+-----------------------------------
          Total |      2,123      100.00

*/

tab course if BroadDef_730_sample_F18 == 1 & IFall2018AssignedBegin730 == 1
/*
      Course |      Freq.     Percent        Cum.
----------------+-----------------------------------
        AT10600 |         33        3.95        3.95
      BIOL11000 |        219       26.23       30.18
      BIOL20300 |        150       17.96       48.14
       COM11400 |         42        5.03       53.17
      ECON25200 |         82        9.82       62.99
      EDCI20500 |         19        2.28       65.27
      EDCI28500 |          8        0.96       66.23
      ENGL10600 |         11        1.32       67.54
        FR20100 |          2        0.24       67.78
        MA15800 |         56        6.71       74.49
        MA16010 |         83        9.94       84.43
        MA16020 |         15        1.80       86.23
      SPAN20200 |          7        0.84       87.07
      STAT11300 |        108       12.93      100.00
----------------+-----------------------------------
          Total |        835      100.00
*/

*------------------------------------------------------------------------------*

**** Table 3: Summary Statistics - Outcome Variables ****

** Summary statistics - outcome variable: Course GPA (Panel 1 of Table 3)
use "${cleandata}sample_course_grades_early_morning.dta",clear
sum CourseGPA if IAssignedBegin730== 1
sum CourseGPA if IAssignedBegin730== 0

** Summary statistics - outcome variable: STEM courses within the next 2 Semester (Panel 2 of Table 3)
use "${cleandata}subsample_stem_early_morning.dta",clear
sum ICorrSTEM_LessEq2_END if IAssignedBegin730 == 1
sum ICorrSTEM_LessEq2_END if IAssignedBegin730 == 0

** Summary statistics - outcome variable: Major choice (Panel 3 of Table 3)
use "${cleandata}subsample_major_early_morning.dta",clear
* Summary statistics - outcome variables
sum Icorrespond_Major1_college if IFall2018AssignedBegin730 == 1 & BroadDef_730_sample_F18 == 1
sum Icorrespond_Major1_college if IFall2018AssignedBegin730 == 0 & BroadDef_730_sample_F18 == 1


** Summary statistics - outcome variable: earnings  (Panel 4 of Table 3)
use "${cleandata}subsample_major_early_morning.dta",clear
sum medsalary if BroadDef_730_sample_F18 == 1 & IFall2018AssignedBegin730 == 1
sum medsalary if BroadDef_730_sample_F18 == 1 & IFall2018AssignedBegin730 == 0 


*------------------------------------------------------------------------------*

**** Table 4: Student-by-Course-by-Term Level Balance Test ****
use "${cleandata}sample_course_grades_early_morning.dta",clear
* no fe
eststo C1:reghdfe IBegin730 female IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T FirstGen ICitizen zsat_combined, vce(cluster id) 
test female IBlack_T IHispanic_T IAsian_T IOthers_T zsat_combined FirstGen ICitizen
estadd scalar fstat_p = round(r(p),0.001)
gen in_sample = e(sample)
keep if in_sample == 1

* course-instructor-term fe
eststo C2: reghdfe IBegin730 female IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T FirstGen ICitizen zsat_combined, absorb(TermxCoursexInstruct) vce(cluster id)
test female IBlack_T IHispanic_T IAsian_T IOthers_T FirstGen zsat_combined ICitizen
estadd scalar fstat_p = round(r(p),0.001)

* course-instructor-term fe and simulated 7:30 section probability
eststo C3:reghdfe IBegin730 female IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T FirstGen ICitizen zsat_combined prob_early_morning_sec, absorb(TermxCoursexInstruct) vce(cluster id) 
test female IBlack_T IHispanic_T IAsian_T IOthers_T zsat_combined FirstGen ICitizen
estadd scalar fstat_p = round(r(p),0.001)

#d ;
esttab C1 C2 C3 using "${results}/balance_test.tex", replace ///
    keep(female IBlack_T IHispanic_T IAsian_T IOthers_T zsat_combined FirstGen ICitizen) ///
    starlevels(* .1 ** .05 *** .01) ///
    cells(b(fmt(3) star) se(par fmt(3))) ///
    stat(fstat_p N r2 , fmt(%16.0gc 3) label("F-stat P-Value" "Observations" "\$R^2$")) ///
    coeflabel(female "Female" ///
              IBlack_T "Black" ///
              IHispanic_T "Hispanic" ///
              IAsian_T "Asian" ///
              IOthers_T "Other Race/Ethnicity" ///
              zsat_combined "Standardized SAT Combined" ///
              FirstGen "First Generation" ///
              ICitizen "Citizen") ///
    collabels(, none) ///
    noabbrev label gaps varwidth(30) booktabs nodep nonum plain fragment nomti ///
    prehead("
    {
    \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
    \begin{tabular}{l*{3}{c}}
    \toprule
    & \multicolumn{1}{c}{(1)} & \multicolumn{1}{c}{(2)} & \multicolumn{1}{c}{(3)} \\
    \midrule") ///
    postfoot("
    Course-Instructor-Term FE & N & Y & Y \\
    Simulated 7:30 AM Section Probability & N & N & Y \\
    \bottomrule
    \end{tabular}
    }") ///
    legend sty(fixed) ;
#d cr



*------------------------------------------------------------------------------*

**** Table 5: Effect of Early Morning Class Assignment on Educational Outcomes ****

** Course Grades (Column 1 of Table 5)
use "${cleandata}sample_course_grades_early_morning.dta",clear
* OLS - column 1
reghdfe CourseGPA IAssignedBegin730, cluster(id)
est store m1

* OLS - column 2
reghdfe CourseGPA IAssignedBegin730 $demo_controls, absorb(TechByCourseByTerm) cluster(id)
est store m2

* OLS - column 3
reghdfe CourseGPA IAssignedBegin730 prob_early_morning_sec $demo_controls, absorb(TechByCourseByTerm) cluster(id)
est store m3

* dependent var mean
sum CourseGPA

* Summary statistics - outcome variables (updated on 6/9/2025)
sum CourseGPA if IAssignedBegin730== 1
sum CourseGPA if IAssignedBegin730== 0

* regression table
esttab m1 m2 m3 using "${results}course_grade_results_ols.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace label


** STEM courses within the next 2 Semester (Column 2 of Table 5)

use "${cleandata}subsample_stem_sample_early_morning.dta",clear

* Col 1
reghdfe ICorrSTEM_LessEq2_END IAssignedBegin730, vce(cluster id)
est store m1

* Col 2
reghdfe ICorrSTEM_LessEq2_END IAssignedBegin730 female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T FirstGen sat_combined IMissingSat_Math IMissingSat_Verbal ICitizen, absorb(CourseByInstByTermFE) vce(cluster id)
est store m2

* Col 3
reghdfe ICorrSTEM_LessEq2_END IAssignedBegin730 female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T FirstGen sat_combined IMissingSat_Math IMissingSat_Verbal ICitizen prob_early_morning_sec, absorb(CourseByInstByTermFE) vce(cluster id)
est store m3

* Dependent variable mean
sum ICorrSTEM_LessEq2_END if corr_STEM_course_sample == 1

* regression table
esttab m1 m2 m3 using "${results}corresponding_STEM_course_within_2semesters_ols.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label

** Major choice (Column 3 of Table 5)
use "${cleandata}subsample_major_early_morning.dta",clear

* col 3
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls, absorb(CourseByInstFE_1) vce(cluster id)
est store m3
gen BroadDef_730_sample_F18 = e(sample)

* col 1
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 if BroadDef_730_sample_F18 ==1, absorb() vce(cluster id)
est store m1

* col 2
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 $demo_controls if BroadDef_730_sample_F18 ==1, absorb(CourseByInstFE_1) vce(cluster id)
est store m2

* dependent variable mean
sum Icorrespond_Major1_college if BroadDef_730_sample_F18 == 1

* Combine the regressions into the same table *
esttab m1 m2 m3 using "${results}majorchoice_broader_def_ols.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label


*------------------------------------------------------------------------------*


**** Table 6: Heterogeneous Effects of Preferred Sections on Student Outcomes****
** Panel A: Course Grades (Columns 1, 2, 3 of Table 6)
use "${cleandata}sample_course_grades_early_morning.dta",clear

* merge the section-preference data
merge m:1 id Academic_Period course section_assigned using "${cleandata}indicator_preferred_sections_Fall2018_Fall2019_Spring2020.dta", keep(1 3) nogen

replace INoPs =1 if IMissingPsTime == 1
replace IMissingPsTime = 0 if IMissingPsTime == 1

* create interation terms
gen IAssigned730xPref730 = IAssignedBegin730*IPsOnly730
gen IAssigned730xPrefNon730 = IAssignedBegin730*IPsOnlyNon730
gen IAssigned730xPrefBoth = IAssignedBegin730*IPsBoth
gen IAssigned730xNoPref = IAssignedBegin730*INoPs

* risk sets method (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}

//ols 

** Course grades

* benchmark regression OLS - course-instructor-term fe, course request controls, demographic controls
reghdfe CourseGPA IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) cluster(id)
est store m1

* OLS - students who only preferred early sections
reghdfe CourseGPA IAssignedBegin730 IPsOnly730 IAssigned730xPref730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) cluster(id)
est store m2

* OLS - students who only preferred non-early sections
reghdfe CourseGPA IAssignedBegin730 IPsOnlyNon730 IAssigned730xPrefNon730 FirstGen $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) cluster(id)
est store m3
 

* output the regression table
esttab m1 m2 m3 using "${results}hetero_grade_preferred_sections_results_ols.tex", star(* 0.10 ** 0.05 *** 0.01) se r2 replace label




** Panel B: STEM Courses (Columns 4, 5, 6 of Table 6)
use "${cleandata}subsample_stem_sample_early_morning.dta",clear

* drop college athelete
drop if ICollegeAthlete == 1

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}

* merge the section-preference data
merge m:1 id Academic_Period course section_assigned using "${cleandata}indicator_preferred_sections_Fall2018_Fall2019_Spring2020.dta", keep(1 3) nogen

* create interation terms
gen IAssigned730xPref730 = IAssignedBegin730*IPsOnly730
gen IAssigned730xPrefNon730 = IAssignedBegin730*IPsOnlyNon730
gen IAssigned730xPrefBoth = IAssignedBegin730*IPsBoth
gen IAssigned730xNoPref = IAssignedBegin730*INoPs


// ols

** within the next 2 Semester
eststo clear

* benchmark
reghdfe ICorrSTEM_LessEq2_END IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(CourseByInstByTermFE) vce(cluster id)
est store m1

* OLS - students who preferred early sections 
reghdfe ICorrSTEM_LessEq2_END IAssignedBegin730 IPsOnly730 IAssigned730xPref730 $demo_controls prob_early_morning_sec, absorb(CourseByInstByTermFE) vce(cluster id)
est store m2

* OLS - students who preferred non-early sections 
reghdfe ICorrSTEM_LessEq2_END IAssignedBegin730 IPsOnlyNon730 IAssigned730xPrefNon730 $demo_controls prob_early_morning_sec, absorb(CourseByInstByTermFE) vce(cluster id)
est store m3


* OLS - students who preferred both sections 
reghdfe ICorrSTEM_LessEq2_END IAssignedBegin730 IPsBoth IAssigned730xPrefBoth $demo_controls prob_early_morning_sec, absorb(CourseByInstByTermFE) vce(cluster id)
est store m4

* Dependent variable mean
sum ICorrSTEM_LessEq2_END

* output the regression table
esttab m1 m2 m3 using "${results}hetero_STEM_courses_preferred_sections_results_ols.tex", star(* 0.10 ** 0.05 *** 0.01) se r2 replace label




** Panel C: Major Choice (Columns 7, 8, 9 of Table 6)

* call the data
use "${cleandata}subsample_major_early_morning.dta",clear

* merge the section-preference data
merge m:1 id Academic_Period course section_assigned using "${cleandata}indicator_preferred_sections_Fall2018_Fall2019_Spring2020.dta", keep(1 3) nogen

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}
 
* merge the section-preference data
merge m:1 id Academic_Period course section_assigned using "${cleandata}indicator_preferred_sections_Fall2018_Fall2019_Spring2020.dta", keep(1 3) nogen

* create interation terms
gen IAssigned730xPref730 = IFall2018AssignedBegin730*IPsOnly730
gen IAssigned730xPrefNon730 = IFall2018AssignedBegin730*IPsOnlyNon730
gen IAssigned730xPrefBoth = IFall2018AssignedBegin730*IPsBoth
gen IAssigned730xNoPref = IFall2018AssignedBegin730*INoPs

// ols

** major choice

* benchmark
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 $demo_controls prob_early_morning_sec, absorb(CourseByInstFE_1) vce(cluster id)
est store m1
gen BroadDef_730_sample_F18 = e(sample)

* OLS - students who preferred early sections 
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 IPsOnly730 IAssigned730xPref730 $demo_controls prob_early_morning_sec if BroadDef_730_sample_F18 == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m2

* OLS - students who preferred non-early sections 
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 IPsOnlyNon730 IAssigned730xPrefNon730 $demo_controls prob_early_morning_sec if BroadDef_730_sample_F18 == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m3

* OLS - students who preferred both sections 
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 IPsBoth IAssigned730xPrefBoth $demo_controls prob_early_morning_sec if BroadDef_730_sample_F18 == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m4

* dependent variable mean
sum Icorrespond_Major1_college if BroadDef_730_sample_F18 == 1

* Combine the regressions into the same table *
esttab m1 m2 m3 using "${results}hetero_major_choice_preferred_sections_results_ols.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label




*------------------------------------------------------------------------------*

**** Table 7: Effect on Choice of STEM Major (College Level) ****

**** STEM and Non-STEM Major Choice
* call the data
use "${cleandata}subsample_major_early_morning.dta",clear
** Combinded
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if BroadDef_730_sample_F18 == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m1
sum Icorrespond_Major1_college if BroadDef_730_sample_F18 == 1

** STEM
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if BroadDef_730_sample_F18 == 1 & I_stem == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m2
sum Icorrespond_Major1_college if BroadDef_730_sample_F18 == 1 & I_stem == 1

** Non-STEM
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if BroadDef_730_sample_F18 == 1 & I_stem == 0, absorb(CourseByInstFE_1) vce(cluster id)
est store m3
sum Icorrespond_Major1_college if BroadDef_730_sample_F18 == 1 & I_stem == 0


* Combine the regressions into the same table *
esttab m1 m2 m3 using "${results}STEM_majorchoice_broader_def_ols.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label





*------------------------------------------------------------------------------*

**** Table 8: Effect on Major Earnings ****

* call the data
use "${cleandata}subsample_major_early_morning.dta",clear


// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}

* generate indicator variables for major earnings
gen I_1stQuartile_earnings_major = (earning_major == 1)
gen I_2ndQuartile_earnings_major = (earning_major <= 2)
gen I_3rdQuartile_earnings_major = (earning_major <= 3)
gen I_25_50th_earnings_major = (earning_major == 2)
gen I_50_75th_earnings_major = (earning_major == 3)
gen I_75_100th_earnings_major = (earning_major == 4)
gen I_Interquartile_earnings_major = (earning_major <=3 & earning_major >=2)

* handling missing medsalary (updated on 1/14/2025)
replace I_1stQuartile_earnings_major =. if medsalary ==.
replace I_2ndQuartile_earnings_major =. if medsalary ==.
replace I_3rdQuartile_earnings_major =. if medsalary ==.  

replace I_25_50th_earnings_major =. if medsalary ==.
replace I_50_75th_earnings_major =. if medsalary ==.
replace I_75_100th_earnings_major =. if medsalary ==.
replace I_Interquartile_earnings_major =. if medsalary ==.  


** Indicator for whether students graduate from the 1st-quartile earning major (Columns 1, 2, 3 of Table 8)
reghdfe I_1stQuartile_earnings_major IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if BroadDef_730_sample_F18 == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m1

reghdfe I_1stQuartile_earnings_major IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if BroadDef_730_sample_F18 == 1 & I_stem == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m2

reghdfe I_1stQuartile_earnings_major IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if BroadDef_730_sample_F18 == 1 & I_stem == 0, absorb(CourseByInstFE_1) vce(cluster id)
est store m3


* Combine the regressions into the same table *
esttab m1 m2 m3  using "${results}Indicator_in_graduating_in_1stQuartile_earnings_major_results_ols.tex", star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label



** Indicator for whether students graduate from the 2nd-quartile earning major (Columns 4, 5, 6 of Table 8)
reghdfe I_25_50th_earnings_major IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if BroadDef_730_sample_F18 == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m1

reghdfe I_25_50th_earnings_major IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if NarrowDef_730_sample_F21 == 1 & I_stem == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m2

reghdfe I_25_50th_earnings_major IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if NarrowDef_730_sample_F21 == 1 & I_stem == 0, absorb(CourseByInstFE_1) vce(cluster id)
est store m3

* dependent variable mean
sum I_25_50th_earnings_major if NarrowDef_730_sample_F21 == 1
sum I_25_50th_earnings_major if I_stem == 1 & NarrowDef_730_sample_F21 == 1
sum I_25_50th_earnings_major if I_stem == 0 & NarrowDef_730_sample_F21 == 1

* Combine the regressions into the same table *
esttab m1 m2 m3  using "${results}Indicator_in_graduating_in_25th_50th_earnings_major_results_ols.tex", star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label



** Indicator for whether students graduate from the 50th-75th percentile earning major (Columns 7, 8, 9 of Table 8)
reghdfe I_50_75th_earnings_major IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if BroadDef_730_sample_F18 == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m1

reghdfe I_50_75th_earnings_major IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if NarrowDef_730_sample_F21 == 1 & I_stem == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m2

reghdfe I_50_75th_earnings_major IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if NarrowDef_730_sample_F21 == 1 & I_stem == 0, absorb(CourseByInstFE_1) vce(cluster id)
est store m3

* dependent variable mean
sum I_50_75th_earnings_major if NarrowDef_730_sample_F21 == 1
sum I_50_75th_earnings_major if I_stem == 1 & NarrowDef_730_sample_F21 == 1
sum I_50_75th_earnings_major if I_stem == 0 & NarrowDef_730_sample_F21 == 1

* Combine the regressions into the same table *
esttab m1 m2 m3  using "${results}Indicator_in_graduating_in_50th_75th_earnings_major_results_ols.tex", star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label



** Indicator for whether students graduate from the 4th-quartile earning major (Columns 10, 11, 12 of Table 8)
reghdfe I_75_100th_earnings_major IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if BroadDef_730_sample_F18 == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m1

reghdfe I_75_100th_earnings_major IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if NarrowDef_730_sample_F21 == 1 & I_stem == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m2

reghdfe I_75_100th_earnings_major IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls if NarrowDef_730_sample_F21 == 1 & I_stem == 0, absorb(CourseByInstFE_1) vce(cluster id)
est store m3

* dependent variable mean
sum I_75_100th_earnings_major if NarrowDef_730_sample_F21 == 1
sum I_75_100th_earnings_major if I_stem == 1 & NarrowDef_730_sample_F21 == 1
sum I_75_100th_earnings_major if I_stem == 0 & NarrowDef_730_sample_F21 == 1

* Combine the regressions into the same table *
esttab m1 m2 m3  using "${results}Indicator_in_graduating_in_highest_25th_percentile_earnings_major_results_ols.tex", star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label


*------------------------------------------------------------------------------*

**** Table 9: Effect of Assigned Early Morning Classes on Students' Class Experiences ****

use "${cleandata}student_survey_data_f22.dta",clear

** Focus on "Strongly Agree" and "Agree" in each question
* Q1
reg IEnjoyAttClassAgreeAb IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store s2_EnjoyAttClass
* Q2
reg IActPartInClassAgreeAb IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store s2_ActPartInClass
* Q3
reg IClassMatePartClassAgreeAb IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store s2_ClassMatePartClass
* Q4
reg ICriticalThinkingAgreeAb IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store s2_CriticalThinking
* Q5
reg IMotivateLearningAgreeAb IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store s2_MotivateLearning
* Q6
reg ILearnMoreDiffSecAgreeAb IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store s2_LearnMoreDiffSec
* Q7
reg IWannaTakeAnotherEconAgreeAb IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store s2_TakeAnotherEcon
* Q8
reg IClearLec_insAgreeAb IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store s2_ClearLec_ins
* Q9
reg IEngagingLec_insAgreeAb IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store s2_EngagingLec_ins
* Q10
reg IHelpMeLearn_insAgreeAb IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store s2_HelpMeLearn_ins
* Q11
reg IEnthusiastic_incAgreeAb IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store s2_Enthusiastic_inc

* extra question
gen attendance = .
replace attendance = 0 if OftenAttend == "0 times"
replace attendance = 1 if OftenAttend == "1 time"
replace attendance = 2 if OftenAttend == "2 times"
replace attendance = 3 if OftenAttend == "3 times"
replace attendance = 4 if OftenAttend == "More than 3 times"

gen I_attend_0 = OftenAttend == "0 times"
gen I_attend_1 = OftenAttend == "1 time"
gen I_attend_2 = OftenAttend == "2 times"
gen I_attend_3 = OftenAttend == "3 times"
gen I_attend_more_than_3 = OftenAttend == "More than 3 times"

reg attendance IAssigned730 IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
sum attendance

* Construct the table
esttab s2_EnjoyAttClass s2_ActPartInClass s2_ClassMatePartClass s2_CriticalThinking s2_MotivateLearning s2_LearnMoreDiffSec s2_TakeAnotherEcon s2_ClearLec_ins s2_EngagingLec_ins s2_HelpMeLearn_ins s2_Enthusiastic_inc using "${results}SA_and_A_StudentSurvey_OLS.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace label

*------------------------------------------------------------------------------*

**** Table 10: Effect on Selective Majors ****


* call the data
use "${cleandata}subsample_major_early_morning.dta",clear

tab majorlongdescription1

gen I_SelectiveMajor = .

replace I_SelectiveMajor=1 if majordescription1=="Accounting"
replace I_SelectiveMajor=1 if majordescription1=="Actuarial Science"
replace I_SelectiveMajor=0 if majordescription1=="Aeronautic Engr Technology"
replace I_SelectiveMajor=0 if majordescription1=="Aerospace Financial Analysis"
replace I_SelectiveMajor=0 if majordescription1=="Agribusiness"
replace I_SelectiveMajor=0 if majordescription1=="Agricultural Communication"
replace I_SelectiveMajor=0 if majordescription1=="Agricultural Economics"
replace I_SelectiveMajor=0 if majordescription1=="Agricultural Education"
replace I_SelectiveMajor=0 if majordescription1=="Agricultural Systems Mgt"
replace I_SelectiveMajor=0 if majordescription1=="Agronomy"
replace I_SelectiveMajor=0 if majordescription1=="Airline Mgmt & Operations"
replace I_SelectiveMajor=0 if majordescription1=="Airport Mgmt & Operations"
replace I_SelectiveMajor=0 if majordescription1=="Animal Sciences"
replace I_SelectiveMajor=0 if majordescription1=="Animation"
replace I_SelectiveMajor=0 if majordescription1=="Anthropology"
replace I_SelectiveMajor=0 if majordescription1=="Applied Meteorology & Climate"
replace I_SelectiveMajor=1 if majordescription1=="Applied Statistics"
replace I_SelectiveMajor=0 if majordescription1=="Atmospheric Science"
replace I_SelectiveMajor=0 if majordescription1=="Audio Engineering Technology"
replace I_SelectiveMajor=0 if majordescription1=="Aviation Management"
replace I_SelectiveMajor=1 if majordescription1=="Biochemistry"
replace I_SelectiveMajor=1 if majordescription1=="Biochemistry (Biology)"
replace I_SelectiveMajor=1 if majordescription1=="Biochemistry (Chemistry)"
replace I_SelectiveMajor=1 if majordescription1=="Biology"
replace I_SelectiveMajor=0 if majordescription1=="Brain and Behavioral Sci"
replace I_SelectiveMajor=0 if majordescription1=="Building Information Modeling"
replace I_SelectiveMajor=1 if majordescription1=="Cell, Molec & Devel Biol"
replace I_SelectiveMajor=1 if majordescription1=="Chemistry"
replace I_SelectiveMajor=1 if majordescription1=="Chemistry (ACS)"
replace I_SelectiveMajor=0 if majordescription1=="Computer & Information Tech"
replace I_SelectiveMajor=1 if majordescription1=="Computer Science"
replace I_SelectiveMajor=0 if majordescription1=="Construction Management"
replace I_SelectiveMajor=0 if majordescription1=="Creative Writing"
replace I_SelectiveMajor=0 if majordescription1=="Cybersecurity"
replace I_SelectiveMajor=1 if majordescription1=="Data Science First Year"
replace I_SelectiveMajor=0 if majordescription1=="Data Visualization"
replace I_SelectiveMajor=0 if majordescription1=="Design & Construct Integration"
replace I_SelectiveMajor=0 if majordescription1=="Developmental & Family Science"
replace I_SelectiveMajor=0 if majordescription1=="Dietetics/NutrFitness & Hlth"
replace I_SelectiveMajor=1 if majordescription1=="Ecol, Evol & Environ Biol"
replace I_SelectiveMajor=1 if majordescription1=="Economics"
replace I_SelectiveMajor=0 if majordescription1=="Electrical Engr Technology"
replace I_SelectiveMajor=0 if majordescription1=="Elementary Education"
replace I_SelectiveMajor=0 if majordescription1=="English"
replace I_SelectiveMajor=1 if majordescription1=="Environmental Geoscience"
replace I_SelectiveMajor=0 if majordescription1=="Envr Health Science"
replace I_SelectiveMajor=0 if majordescription1=="Explorers"
replace I_SelectiveMajor=1 if majordescription1=="Finance"
replace I_SelectiveMajor=0 if majordescription1=="Financial Counseling& Planning"
replace I_SelectiveMajor=1 if majordescription1=="First Year Engineering"
replace I_SelectiveMajor=0 if majordescription1=="Fisheries & Aquatic Sciences"
replace I_SelectiveMajor=0 if majordescription1=="Food Science"
replace I_SelectiveMajor=0 if majordescription1=="Foods & Nutrition in Business"
replace I_SelectiveMajor=0 if majordescription1=="Forestry"
replace I_SelectiveMajor=0 if majordescription1=="Game Development and Design"
replace I_SelectiveMajor=0 if majordescription1=="Gen-Ed Educational Studies"
replace I_SelectiveMajor=1 if majordescription1=="General Management"
replace I_SelectiveMajor=0 if majordescription1=="General Undecided"
replace I_SelectiveMajor=1 if majordescription1=="Genetics"
replace I_SelectiveMajor=1 if majordescription1=="Geology & Geophysics"
replace I_SelectiveMajor=0 if majordescription1=="Global Studies"
replace I_SelectiveMajor=0 if majordescription1=="Health Science PreProfessional"
replace I_SelectiveMajor=1 if majordescription1=="Health and Disease"
replace I_SelectiveMajor=0 if majordescription1=="History"
replace I_SelectiveMajor=0 if majordescription1=="Horticulture"
replace I_SelectiveMajor=0 if majordescription1=="Hospitality & Tourism Mgmt"
replace I_SelectiveMajor=0 if majordescription1=="Human Services"
replace I_SelectiveMajor=1 if majordescription1=="IM/Engineering"
replace I_SelectiveMajor=0 if majordescription1=="Industrial Design Prof Program"
replace I_SelectiveMajor=0 if majordescription1=="Industrial Engineering Tech"
replace I_SelectiveMajor=0 if majordescription1=="Insect Biology"
replace I_SelectiveMajor=0 if majordescription1=="Interdisc Film/Video"
replace I_SelectiveMajor=0 if majordescription1=="Interior Design Prof Program"
replace I_SelectiveMajor=0 if majordescription1=="Kinesiology"
replace I_SelectiveMajor=0 if majordescription1=="Law and Society"
replace I_SelectiveMajor=0 if majordescription1=="Linguistics"
replace I_SelectiveMajor=1 if majordescription1=="Marketing"
replace I_SelectiveMajor=1 if majordescription1=="Mathematics"
replace I_SelectiveMajor=0 if majordescription1=="Mathematics Education"
replace I_SelectiveMajor=0 if majordescription1=="Mechanical Engr Technology"
replace I_SelectiveMajor=0 if majordescription1=="Mechatronics Engr Tech"
replace I_SelectiveMajor=0 if majordescription1=="Medical Laboratory Sciences"
replace I_SelectiveMajor=1 if majordescription1=="Microbiology"
replace I_SelectiveMajor=0 if majordescription1=="Natural Resources& Envrmtl Sci"
replace I_SelectiveMajor=0 if majordescription1=="Network Engineering Tech"
replace I_SelectiveMajor=1 if majordescription1=="Neurobiology & Physiology"
replace I_SelectiveMajor=1 if majordescription1=="Nursing"
replace I_SelectiveMajor=0 if majordescription1=="Nutrition & Dietetics"
replace I_SelectiveMajor=0 if majordescription1=="Nutrition Science"
replace I_SelectiveMajor=0 if majordescription1=="Nutrition, Fitness & Health"
replace I_SelectiveMajor=0 if majordescription1=="Occupational Health Science"
replace I_SelectiveMajor=0 if majordescription1=="Organizational Leadership"
replace I_SelectiveMajor=0 if majordescription1=="Pharmaceutical Sciences"
replace I_SelectiveMajor=0 if majordescription1=="Philosophy"
replace I_SelectiveMajor=1 if majordescription1=="Physics"
replace I_SelectiveMajor=1 if majordescription1=="Planetary Sciences"
replace I_SelectiveMajor=0 if majordescription1=="Plant Genetic Breeding Biotech"
replace I_SelectiveMajor=0 if majordescription1=="Political Science"
replace I_SelectiveMajor=0 if majordescription1=="Pre Agr & Biol Engineering"
replace I_SelectiveMajor=0 if majordescription1=="Pre Athletic Training"
replace I_SelectiveMajor=0 if majordescription1=="Pre Communication"
replace I_SelectiveMajor=1 if majordescription1=="Pre Economics"
replace I_SelectiveMajor=0 if majordescription1=="Pre Environmental Studies"
replace I_SelectiveMajor=0 if majordescription1=="Pre Landscape Architecture"
replace I_SelectiveMajor=1 if majordescription1=="Pre Mgmt/Accounting"
replace I_SelectiveMajor=1 if majordescription1=="Pre Mgmt/General Management"
replace I_SelectiveMajor=1 if majordescription1=="Pre Mgmt/Indust Management"
replace I_SelectiveMajor=0 if majordescription1=="Pre Veterinary Medicine"
replace I_SelectiveMajor=1 if majordescription1=="Pre-Finance"
replace I_SelectiveMajor=1 if majordescription1=="Pre-Marketing"
replace I_SelectiveMajor=1 if majordescription1=="Pre-Supply Chain Info/Analytic"
replace I_SelectiveMajor=0 if majordescription1=="Prof Flight Technology"
replace I_SelectiveMajor=0 if majordescription1=="Professional Writing"
replace I_SelectiveMajor=0 if majordescription1=="Psychological Sciences"
replace I_SelectiveMajor=0 if majordescription1=="Public Health"
replace I_SelectiveMajor=0 if majordescription1=="Radiological Health Sciences"
replace I_SelectiveMajor=0 if majordescription1=="Retail Management"
replace I_SelectiveMajor=0 if majordescription1=="Robotics Engr Technology"
replace I_SelectiveMajor=0 if majordescription1=="Sales And Marketing"
replace I_SelectiveMajor=0 if majordescription1=="Selling & Sales Management"
replace I_SelectiveMajor=0 if majordescription1=="Social Studies Education"
replace I_SelectiveMajor=0 if majordescription1=="Sociology"
replace I_SelectiveMajor=0 if majordescription1=="Sound for the Performing Arts"
replace I_SelectiveMajor=0 if majordescription1=="Special Ed/Elem Education"
replace I_SelectiveMajor=0 if majordescription1=="Special Education: Mild/In-P12"
replace I_SelectiveMajor=0 if majordescription1=="Speech, Language & Hearing Sci"
replace I_SelectiveMajor=1 if majordescription1=="Statistics-Math Emphasis"
replace I_SelectiveMajor=0 if majordescription1=="Studio Arts & Technology"
replace I_SelectiveMajor=1 if majordescription1=="Supply Chain Info & Analytics"
replace I_SelectiveMajor=0 if majordescription1=="Sustainable Biomaterials"
replace I_SelectiveMajor=0 if majordescription1=="Sustainable Food & Farm Systms"
replace I_SelectiveMajor=0 if majordescription1=="Systems Analysis & Design"
replace I_SelectiveMajor=0 if majordescription1=="Technology Education"
replace I_SelectiveMajor=0 if majordescription1=="Theatre Concentration"
replace I_SelectiveMajor=0 if majordescription1=="Transdisc Studies in Engr Tech"
replace I_SelectiveMajor=0 if majordescription1=="Turf Management & Science"
replace I_SelectiveMajor=0 if majordescription1=="UX Design"
replace I_SelectiveMajor=0 if majordescription1=="Unmanned Aerial Systems"
replace I_SelectiveMajor=0 if majordescription1=="Veterinary Nurse"
replace I_SelectiveMajor=0 if majordescription1=="Virtual Product Integration"
replace I_SelectiveMajor=0 if majordescription1=="Visual Arts Education"
replace I_SelectiveMajor=0 if majordescription1=="Visual Effects Compositing"
replace I_SelectiveMajor=0 if majordescription1=="Wildlife"
replace I_SelectiveMajor=0 if majordescription1=="Women's Studies"


* Combinded - col 1
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 $demo_controls prob_early_morning_sec if BroadDef_730_sample_F18 == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m1
sum Icorrespond_Major1_college if BroadDef_730_sample_F18 == 1

* Selective Major - col 2
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 $demo_controls prob_early_morning_sec if BroadDef_730_sample_F18 == 1 & I_SelectiveMajor == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m2
sum Icorrespond_Major1_college if BroadDef_730_sample_F18 == 1 & I_SelectiveMajor == 1

gen I_SelectiveMajorXEarlyMorning = I_SelectiveMajor*IFall2018AssignedBegin730
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 I_SelectiveMajor I_SelectiveMajorXEarlyMorning $demo_controls prob_early_morning_sec if BroadDef_730_sample_F18 == 1, absorb(CourseByInstFE_1) vce(cluster id)

* Non-Selective Major col 3
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 $demo_controls prob_early_morning_sec if BroadDef_730_sample_F18 == 1 & I_SelectiveMajor == 0, absorb(CourseByInstFE_1) vce(cluster id)
est store m3					   
sum Icorrespond_Major1_college if BroadDef_730_sample_F18 == 1 & I_SelectiveMajor == 0

* Combine the regressions into the same table *
esttab m1 m2 m3 using "${results}selective_majorchoice_broader_def_ols.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label




**** Table 11: ffect of Attending Subsequent Classes on Course Grades ****

cls
clear all

* call the data
use "${cleandata}TestingGradeEffectofBack2BackCourses_at38.dta"

drop if ICollegeAthlete == 1

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}


* outcome variable: gpa
local CRC_DC_Do female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T FirstGen sat_combined IMissingSat_Math IMissingSat_Verbal ICitizen
reghdfe gpa ISubseqClass `CRC_DC_Do', absorb(CourseTimeByInstByTerm) vce(cluster id)
est store m1
gen in_sample = e(sample)
sum gpa if in_sample == 1

* outcome variable: IGreaterB
local CRC_DC_Do female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T FirstGen sat_combined IMissingSat_Math IMissingSat_Verbal ICitizen
reghdfe IGreaterB ISubseqClass `CRC_DC_Do' if in_sample == 1, absorb(CourseTimeByInstByTerm) vce(cluster id)
est store m2
sum IGreaterB if in_sample == 1

* outcome variable: IGetA
local CRC_DC_Do female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T FirstGen sat_combined IMissingSat_Math IMissingSat_Verbal ICitizen
reghdfe IGetA ISubseqClass `CRC_DC_Do' if in_sample == 1, absorb(CourseTimeByInstByTerm) vce(cluster id)
est store m3
sum IGetA  if in_sample == 1

* outcome variable: IGetC
local CRC_DC_Do female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T FirstGen sat_combined IMissingSat_Math IMissingSat_Verbal ICitizen
reghdfe IGetC ISubseqClass `CRC_DC_Do' if in_sample == 1, absorb(CourseTimeByInstByTerm) vce(cluster id)
est store m4
sum IGetC if in_sample == 1

* regression tables
esttab m1 m2 m3 m4 using "${results}effect_subsequent_classes.tex", star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label




**** Table 12: Correlation between Major Choice and Standardized Course Grades ****

* call the data
use "${cleandata}subsample_major_early_morning.dta",clear


// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}

eststo clear

* generate course grade measure
gen CourseGPA = .
replace CourseGPA = 4 if finalgrade == "A" | finalgrade == "A+"
replace CourseGPA = 3.7 if finalgrade == "A-"
replace CourseGPA = 3.3 if finalgrade == "B+"
replace CourseGPA = 3 if finalgrade == "B"
replace CourseGPA = 2.7 if finalgrade == "B-"
replace CourseGPA = 2.3 if finalgrade == "C+"
replace CourseGPA = 2 if finalgrade == "C"
replace CourseGPA = 1.7 if finalgrade == "C-"
replace CourseGPA = 1.3 if finalgrade == "D+"
replace CourseGPA = 1 if finalgrade == "D"
replace CourseGPA = 0.7 if finalgrade == "D-"
replace CourseGPA = 0 if finalgrade == "E" | finalgrade == "F"

* Combinded
reghdfe Icorrespond_Major1_college CourseGPA $demographic prob_early_morning_sec if BroadDef_730_sample_F18 == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m1

* STEM
reghdfe Icorrespond_Major1_college CourseGPA $demographic prob_early_morning_sec if BroadDef_730_sample_F18 == 1 & I_stem == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m2

* Non-STEM
reghdfe Icorrespond_Major1_college CourseGPA $demographic prob_early_morning_sec if BroadDef_730_sample_F18 == 1 & I_stem == 0, absorb( CourseByInstFE_1) vce(cluster id section_assigned)
est store m3

* Combine the regressions into the same table *
esttab m1 m2 m3 using "${results}correlation_STEM_major_choice_course_grades_ols.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label




////////////////////////////////////////////////////////////////////////////////
///																			 ///
///	 Codes to generate all the appendix figures and tables in this paper	 ///
///																			 ///
////////////////////////////////////////////////////////////////////////////////


*------------------------------------------------------------------------------*

**** Figure A.1: Course Request Form ****

/*
Not applicable 

*/


**** Figure A.2: Distribution of Residuals from Simulated 7:30 AM Assignment Probability ****

** Figure A. Main Sample **
use "${cleandata}sample_course_grades_early_morning.dta",clear

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}

* distribution of "expected treatment"

* how much variation is there in 'expected treatment' within course-by-instructor-by-term for the type (i) sample?
encode TechByCourseByTerm, gen(TechByCourseByTerm_encoded)
bysort TechByCourseByTerm_encoded: sum prob_early_morning_sec

reg prob_early_morning_sec i.TechByCourseByTerm_encoded 
predict residuals_course_grades, residuals 
sum residuals_course_grades

//     title("Distribution of Residuals from Expected Treatment") ///
// Generate the histogram
histogram residuals_course_grades, ///
    xtitle("Residuals (Net of Course-Instructor-Term Fixed Effects)") ///
    ytitle("Density") ///
    percent ///
    normal ///
    width(0.05) ///
    graphregion(color(white)) ///
    lcolor(black)
	
// Export the graph to a PNG file
graph export "${results}distribution_resid_simulated_prob_course_grades_editor_comment_2d.png", width(1200) replace


** Figure B. STEM Courses Subsample **
use "${cleandata}subsample_stem_sample_early_morning.dta",clear


// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}

* how much variation is there in 'expected treatment' within course-by-instructor-by-term for the type (i) sample?
bysort CourseByInstByTermFE: sum prob_early_morning_sec

encode CourseByInstByTermFE, gen(CourseByInstByTermFE_encoded)
reg prob_early_morning_sec i.CourseByInstByTermFE_encoded 
predict residuals_STEM_courses, residuals 
sum residuals_STEM_courses


//     title("Distribution of Residuals from Expected Treatment") ///
// Generate the histogram
histogram residuals_STEM_courses, ///
    xtitle("Residuals (Net of Course-Instructor-Term Fixed Effects)") ///
    ytitle("Density") ///
    percent ///
    normal ///
    width(0.05) ///
    graphregion(color(white)) ///
    lcolor(black)
	
// Export the graph to a PNG file
graph export "${results}distribution_resid_simulated_prob_STEM_courses_editor_comment_2d.png", width(1200) replace

** Figure C. Major Choice Subsample **
use "${cleandata}subsample_major_early_morning.dta",clear

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}

* how much variation is there in 'expected treatment' within course-by-instructor-by-term for the type (i) sample?
bysort CourseByInstFE_1: sum prob_early_morning_sec

encode CourseByInstFE_1, gen(CourseByInstFE_1_encoded)
reg prob_early_morning_sec i.CourseByInstFE_1_encoded 
predict residuals_major, residuals 
sum residuals_major


//     title("Distribution of Residuals from Expected Treatment") ///
// Generate the histogram
histogram residuals_major, ///
    xtitle("Residuals (Net of Course-Instructor-Term Fixed Effects)") ///
    ytitle("Density") ///
    percent ///
    normal ///
    width(0.05) ///
    graphregion(color(white)) ///
    lcolor(black)
	
// Export the graph to a PNG file
graph export "${results}distribution_resid_simulated_prob_major_editor_comment_2d.png", width(1200) replace

*------------------------------------------------------------------------------*

**** Table A.1: Courses in the Three Samples ****


** Columns 1 and 2 of Table A.1 **

* course grades
use "${cleandata}sample_course_grades_early_morning.dta",clear

** Summary statistics (main sample - Tables 1 and 2)
* Label demographic variables *
label variable female "Female"
label variable IWhite_T "White"
label variable IBlack_T "Black"
label variable IHispanic_T "Hispanic"
label variable IAsian_T "Asian"
label variable IOthers_T "Others"
label variable FirstGen "1st Gen Student"
label variable sat_combined "SAT Combined"
label variable ICitizen "Citizen"

tab course 

/*
      Course |      Freq.     Percent        Cum.
----------------+-----------------------------------
        AT10600 |         82        1.46        1.46
      BIOL11000 |      1,886       33.61       35.07
      BIOL11200 |          6        0.11       35.17
      BIOL20300 |        759       13.52       48.70
       COM11400 |         80        1.43       50.12
      ECON25200 |        152        2.71       52.83
      EDCI20500 |         24        0.43       53.26
      EDCI28500 |         10        0.18       53.44
      ENGL10600 |         20        0.36       53.80
        FR20100 |          8        0.14       53.94
        MA15800 |        774       13.79       67.73
        MA16010 |      1,451       25.86       93.59
        MA16020 |         72        1.28       94.87
      SPAN20100 |          6        0.11       94.98
      SPAN20200 |         12        0.21       95.19
      STAT11300 |        270        4.81      100.00
----------------+-----------------------------------
          Total |      5,612      100.00

*/

tab course if IAssignedBegin730 == 1
/*
        Course |      Freq.     Percent        Cum.
----------------+-----------------------------------
        AT10600 |         59        3.27        3.27
      BIOL11000 |        562       31.14       34.40
      BIOL11200 |          2        0.11       34.52
      BIOL20300 |        326       18.06       52.58
       COM11400 |         41        2.27       54.85
      ECON25200 |        148        8.20       63.05
      EDCI20500 |         17        0.94       63.99
      EDCI28500 |          8        0.44       64.43
      ENGL10600 |          8        0.44       64.88
        FR20100 |          2        0.11       64.99
        MA15800 |        158        8.75       73.74
        MA16010 |        232       12.85       86.59
        MA16020 |         29        1.61       88.20
      SPAN20100 |          5        0.28       88.48
      SPAN20200 |          5        0.28       88.75
      STAT11300 |        203       11.25      100.00
----------------+-----------------------------------
          Total |      1,805      100.00



*/

** Columns 3 and 4 of Table A.1 **

* Stem courses
use "${cleandata}subsample_stem_sample_early_morning.dta",clear

* Label demographic variables *
label variable female "Female"
label variable IWhite_T "White"
label variable IBlack_T "Black"
label variable IHispanic_T "Hispanic"
label variable IAsian_T "Asian"
label variable IOthers_T "Others"
label variable FirstGen "1st Gen Student"
label variable sat_combined "SAT Combined"
label variable ICitizen "Citizen"
label variable CourseRequestedCount "Requested Courses"

tab course

/*

         Course |      Freq.     Percent        Cum.
----------------+-----------------------------------
        AT10600 |         45        1.29        1.29
      BIOL11000 |      1,233       35.38       36.67
      BIOL11200 |          6        0.17       36.84
      BIOL20300 |        503       14.43       51.28
      ECON25200 |         77        2.21       53.49
        MA15800 |        532       15.27       68.75
        MA16010 |        914       26.23       94.98
        MA16020 |         37        1.06       96.04
      STAT11300 |        138        3.96      100.00
----------------+-----------------------------------
          Total |      3,485      100.00


*/

tab course if IAssignedBegin730==1
/*
        Course |      Freq.     Percent        Cum.
----------------+-----------------------------------
        AT10600 |         33        3.03        3.03
      BIOL11000 |        383       35.14       38.17
      BIOL11200 |          2        0.18       38.35
      BIOL20300 |        201       18.44       56.79
      ECON25200 |         76        6.97       63.76
        MA15800 |        113       10.37       74.13
        MA16010 |        161       14.77       88.90
        MA16020 |         15        1.38       90.28
      STAT11300 |        106        9.72      100.00
----------------+-----------------------------------
          Total |      1,090      100.00


*/


** Columns 5 and 6 of Table A.1 **

* for major choice and earning
use "${cleandata}subsample_major_early_morning.dta",clear


* Label demographic variables *
label variable female "Female"
label variable IWhite_T "White"
label variable IBlack_T "Black"
label variable IHispanic_T "Hispanic"
label variable IAsian_T "Asian"
label variable IOthers_T "Others"
label variable FirstGen "1st Gen Student"
label variable sat_combined "SAT Combined"
label variable ICitizen "Citizen"
label variable CourseRequestedCount "Requested Courses"


tab course if BroadDef_730_sample_F18 == 1
/*

         Course |      Freq.     Percent        Cum.
----------------+-----------------------------------
        AT10600 |         47        2.21        2.21
      BIOL11000 |        603       28.40       30.62
      BIOL20300 |        291       13.71       44.32
       COM11400 |         88        4.15       48.47
      ECON25200 |         85        4.00       52.47
      EDCI20500 |         28        1.32       53.79
      EDCI28500 |         11        0.52       54.31
      ENGL10600 |         37        1.74       56.05
        FR20100 |          9        0.42       56.48
        MA15800 |        241       11.35       67.83
        MA16010 |        485       22.85       90.67
        MA16020 |         38        1.79       92.46
      SPAN20200 |         16        0.75       93.22
      STAT11300 |        144        6.78      100.00
----------------+-----------------------------------
          Total |      2,123      100.00

*/

tab course if BroadDef_730_sample_F18 == 1 & IFall2018AssignedBegin730 == 1
/*
      Course |      Freq.     Percent        Cum.
----------------+-----------------------------------
        AT10600 |         33        3.95        3.95
      BIOL11000 |        219       26.23       30.18
      BIOL20300 |        150       17.96       48.14
       COM11400 |         42        5.03       53.17
      ECON25200 |         82        9.82       62.99
      EDCI20500 |         19        2.28       65.27
      EDCI28500 |          8        0.96       66.23
      ENGL10600 |         11        1.32       67.54
        FR20100 |          2        0.24       67.78
        MA15800 |         56        6.71       74.49
        MA16010 |         83        9.94       84.43
        MA16020 |         15        1.80       86.23
      SPAN20200 |          7        0.84       87.07
      STAT11300 |        108       12.93      100.00
----------------+-----------------------------------
          Total |        835      100.00
*/


**** Table A.2: Mapping Between Courses and Colleges ****

* for major choice and earning
use "${cleandata}subsample_major_early_morning.dta",clear

** Mapping Between Coursews and Colleges
sum Icorrespond_Major1_college if course == "ECON25200" & BroadDef_730_sample_F18 == 1
sum Icorrespond_Major1_college if course == "EDCI20500" & BroadDef_730_sample_F18 == 1
sum Icorrespond_Major1_college if course == "EDCI28500" & BroadDef_730_sample_F18 == 1
sum Icorrespond_Major1_college if course == "COM11400" & BroadDef_730_sample_F18 == 1
sum Icorrespond_Major1_college if course == "ENGL10600" & BroadDef_730_sample_F18 == 1

sum Icorrespond_Major1_college if course == "FR20100" & BroadDef_730_sample_F18 == 1
sum Icorrespond_Major1_college if course == "SPAN20200" & BroadDef_730_sample_F18 == 1
sum Icorrespond_Major1_college if course == "AT10600" & BroadDef_730_sample_F18 == 1
sum Icorrespond_Major1_college if course == "BIOL11000" & BroadDef_730_sample_F18 == 1
sum Icorrespond_Major1_college if course == "BIOL20300" & BroadDef_730_sample_F18 == 1

sum Icorrespond_Major1_college if course == "MA15800" & BroadDef_730_sample_F18 == 1
sum Icorrespond_Major1_college if course == "MA16010" & BroadDef_730_sample_F18 == 1
sum Icorrespond_Major1_college if course == "MA16020" & BroadDef_730_sample_F18 == 1
sum Icorrespond_Major1_college if course == "STAT11300" & BroadDef_730_sample_F18 == 1

/*
title_short_desc_assigned		course		course_college				fraction
Macroeconomics					ECON25200	Business					0.424
Exploring Teaching				EDCI20500	Education					0.571
Multiculturalism & Edu			EDCI28500	Education					0.636
Fundament Of Speech				COM11400	Liberal Arts				0.0909
First-Year Composition			ENGL10600	Liberal Arts				0.162
French Level III				FR20100		Liberal Arts				0.111
Spanish Level IV				SPAN20200	Liberal Arts				0.313
Basic Aircraft Science			AT10600		Polytechnic Institute		0.936
Fundamentals Biol I				BIOL11000	Science						0.0365
Human Antmy & Physiol			BIOL20300	Science						0.0103
Precalculus- Functions & Trig	MA15800		Science						0.705
Applied Calculus I				MA16010		Science						0.103
Applied Calculus II				MA16020		Science						0.211
Statistics & Society			STAT11300	Science						0.139
*/





**** Table A.3: Summary Statistics of Simulated 7:30 AM Assignment Probability (Expected Treatment) ****

** Main Sample (Course Grades) - Row 1 of Table A.3

* call the data
use "${cleandata}sample_course_grades_early_morning.dta",clear

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}


* distribution of "expected treatment"
sum prob_early_morning_sec

/*

* Main Sample (Row 1 of Table A.3)

  Variable 							  |        Obs        Mean    Std. dev.       Min        Max
-------------+----------------------------------------------------------------------------------
Simulated 7:30 AM Section Probability |      5,612    .1923574    .2388548          0          1

*/



** STEM Courses Subsample - Row 2 of Table A.3

* Call the data
use "${cleandata}subsample_stem_sample_early_morning.dta",clear

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}



* distribution of "expected treatment"
sum prob_early_morning_sec

/*


* Subsample - STEM Courses (Row 2 of Table A.3)

   Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
prob_early~c |      3,485    .1881119    .2353896          0          1


*/



** Major Choice Subsample - Row 3 of Table A.3

* Call the data
use "${cleandata}subsample_major_early_morning.dta",clear

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}

* distribution of "expected treatment"
sum prob_early_morning_sec 

/*

* Subsample - Major (Row 3 of Table A.3)

   Variable |        Obs        Mean    Std. dev.       Min        Max
-------------+---------------------------------------------------------
prob_early~c |      2,123    .2150683    .2554544          0          1


*/

**** Table A.4: First Stage Estimates ****

* Call the data 
use "${cleandata}sample_course_grades_early_morning.dta",clear

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}

* col 1 - no controls and no fe
encode TechByCourseByTerm, gen(TechByCourseByTerm_encoded)
reghdfe IEndBegin730 IAssignedBegin730 if course_grade_all_students_sample == 1, cluster(id)
est store m1

ivreghdfe CourseGPA (IEndBegin730 = IAssignedBegin730) if course_grade_all_students_sample == 1, vce(cluster id)

* col 2 - course-instructor-term fe, demographic controls (F-Statistics: xxxxx)
reghdfe IEndBegin730 IAssignedBegin730 $demo_controls if course_grade_all_students_sample == 1, absorb(TechByCourseByTerm) cluster(id)
est store m2

ivreghdfe CourseGPA (IEndBegin730 = IAssignedBegin730) $demo_controls i.TechByCourseByTerm_encoded if course_grade_all_students_sample == 1,  cluster(id) 

*  col 3 - simulated 7:30 am section probabilities (F-Statistics: xxxxx)
reghdfe IEndBegin730 IAssignedBegin730 $demo_controls prob_early_morning_sec if course_grade_all_students_sample == 1, absorb( TechByCourseByTerm) cluster(id)
est store m3

ivreghdfe CourseGPA (IEndBegin730 = IAssignedBegin730) $demo_controls i.TechByCourseByTerm_encoded prob_early_morning_sec if course_grade_all_students_sample == 1,  cluster(id) 

* Construct a regression table
esttab m1 m2 m3 using "${results}1st_stage_course_grade.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace label



**** Table A.5: Effect on Course Grades ****


** Effect on Course Grade (updated on 1/24/2025)

* Call the data
use "${cleandata}sample_course_grades_early_morning.dta",clear

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}


// Panel 1: 2SLS Estimates

* 2SLS - column 1
encode TechByCourseByTerm, gen(TechByCourseByTerm_encoded)

reghdfe CourseGPA IAssignedBegin730, cluster(id)
ivreghdfe CourseGPA (IEndBegin730 = IAssignedBegin730), cluster(id)
est store m1

* 2SLS - column 2
ivreghdfe CourseGPA i.TechByCourseByTerm_encoded $demo_controls (IEndBegin730 = IAssignedBegin730), cluster(id)
est store m2

* 2SLS - column 3
ivreghdfe CourseGPA (IEndBegin730 = IAssignedBegin730) $demo_controls prob_early_morning_sec i.TechByCourseByTerm_encoded,  cluster(id) 
est store m3

* regression table
esttab m1 m2 m3 using "${results}course_grade_results_2sls.tex", star(* 0.10 ** 0.05 *** 0.01) se r2 replace label

// Panel 2: Reduced Form Estimates
* OLS - column 1 
reghdfe CourseGPA IAssignedBegin730, cluster(id)
est store m1

* OLS - column 2
reghdfe CourseGPA IAssignedBegin730 $demo_controls, absorb(TechByCourseByTerm) cluster(id)
est store m2

* OLS - column 3
reghdfe CourseGPA IAssignedBegin730 prob_early_morning_sec $demo_controls, absorb(TechByCourseByTerm) cluster(id)
est store m3

* dependent var mean
sum CourseGPA

* Summary statistics - outcome variables (updated on 6/9/2025)
sum CourseGPA if IAssignedBegin730== 1
sum CourseGPA if IAssignedBegin730== 0

* regression table
esttab m1 m2 m3 using "${results}course_grade_results_ols.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace label



**** Table A.6: Effect on STEM Courses within the Next 2 Terms ****

* Stem courses
use "${cleandata}subsample_stem_sample_early_morning.dta",clear


// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}

// Panel 1: 2SLS Estimates
eststo clear

* col 1
ivreghdfe ICorrSTEM_LessEq2_END (IEndBegin730 = IAssignedBegin730) if corr_STEM_course_sample == 1, absorb() cluster(id)
est store m1

* col 2
ivreghdfe ICorrSTEM_LessEq2_END (IEndBegin730 = IAssignedBegin730) $demo_controls if corr_STEM_course_sample == 1, absorb(CourseByInstByTermFE) cluster(id)
est store m2

* col 3
ivreghdfe ICorrSTEM_LessEq2_END (IEndBegin730 = IAssignedBegin730) $demo_controls prob_early_morning_sec if corr_STEM_course_sample == 1, absorb(CourseByInstByTermFE) cluster(id)
est store m3

* Dependent variable mean
sum ICorrSTEM_LessEq2_END if corr_STEM_course_sample == 1

* Construct a regression table
esttab m1 m2 m3 using "${results}corresponding_STEM_course_within_2semesters_2sls.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace label


// Panel 2: Reduced Form Estimates 
* Col 1
reghdfe ICorrSTEM_LessEq2_END IAssignedBegin730, vce(cluster id)
est store m1

* Col 2
reghdfe ICorrSTEM_LessEq2_END IAssignedBegin730 female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T FirstGen sat_combined IMissingSat_Math IMissingSat_Verbal ICitizen, absorb(CourseByInstByTermFE) vce(cluster id)
est store m2

* Col 3
reghdfe ICorrSTEM_LessEq2_END IAssignedBegin730 female IWhite_T IBlack_T IHispanic_T IAsian_T IOthers_T IMissingRace_T FirstGen sat_combined IMissingSat_Math IMissingSat_Verbal ICitizen prob_early_morning_sec, absorb(CourseByInstByTermFE) vce(cluster id)
est store m3

* regression table
esttab m1 m2 m3 using "${results}corresponding_STEM_course_within_2semesters_ols.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label

* Dependent variable mean
sum ICorrSTEM_LessEq2_END if corr_STEM_course_sample == 1



**** Table A.7: Effect on Choice of Major (College Level) ****

* Call the data
use "${cleandata}subsample_major_early_morning.dta",clear

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}


** Major choice

// Panel 2: Reduced Form Estimates 
* col 3
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 prob_early_morning_sec $demo_controls, absorb(CourseByInstFE_1) vce(cluster id)
est store m3
gen BroadDef_730_sample_F18 = e(sample)

* col 1
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 if BroadDef_730_sample_F18 ==1, absorb() vce(cluster id)
est store m1

* col 2
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 $demo_controls if BroadDef_730_sample_F18 ==1, absorb(CourseByInstFE_1) vce(cluster id)
est store m2

sum Icorrespond_Major1_college if BroadDef_730_sample_F18 == 1

* dependent variable mean
sum Icorrespond_Major1_college if BroadDef_730_sample_F18 == 1

* Combine the regressions into the same table *
esttab m1 m2 m3 using "${results}majorchoice_broader_def_ols.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label


// Panel 1: 2SLS Estimates
* col 1
ivreghdfe Icorrespond_Major1_college (IFall2018EndBegin730 = IFall2018AssignedBegin730), absorb() cluster(id)
est store m1

* col 2
ivreghdfe Icorrespond_Major1_college (IFall2018EndBegin730 = IFall2018AssignedBegin730) $demo_controls, absorb(CourseByInstFE_1) cluster(id)
est store m2

* col 3
ivreghdfe Icorrespond_Major1_college (IFall2018EndBegin730 = IFall2018AssignedBegin730) $demo_controls prob_early_morning_sec, absorb(CourseByInstFE_1) cluster(id)
est store m3

* Combine the regressions into the same table *
esttab m1 m2 m3 using "${results}majorchoice_broader_def_2sls.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label


**** Table A.8: Effect on Corresponding STEM Courses in the Next Term ****

* Call the data
use "${cleandata}subsample_major_early_morning.dta",clear

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}


// Panel 1: 2SLS Estimates

eststo clear
* col 1
ivreghdfe ICorrSTEM_END1 (IEndBegin730 = IAssignedBegin730), cluster(id)
est store m1

* col 2
ivreghdfe ICorrSTEM_END1 (IEndBegin730 = IAssignedBegin730) $demo_controls, absorb(CourseByInstByTermFE) cluster(id)
est store m2

* col 3
ivreghdfe ICorrSTEM_END1 (IEndBegin730 = IAssignedBegin730) $demo_controls prob_early_morning_sec, absorb(CourseByInstByTermFE) cluster(id)
est store m3

* dependent variable mean
sum ICorrSTEM_END1 if corr_STEM_course_sample == 1

* Construct a regression table
esttab m1 m2 m3  using "${results}corresponding_STEM_next_semester_2sls.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace label


// Panel 2: Reduced Form Estimates 
* col 1
reghdfe ICorrSTEM_END1 IAssignedBegin730, vce(cluster id)
est store m1

* col 2
reghdfe ICorrSTEM_END1 IAssignedBegin730 $demo_controls, absorb(CourseByInstByTermFE) vce(cluster id)
est store m2

* col 3
reghdfe ICorrSTEM_END1 IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(CourseByInstByTermFE) vce(cluster id)
est store m3


* regression table
esttab m1 m2 m3 using "${results}corresponding_STEM_next_semester_ols.tex", star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label










**** Table A.9: Heterogeneous Effect on Choice of Major (College Level) ****

* Call the data
use "${cleandata}subsample_major_early_morning.dta",clear

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}

* benchmark
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 $demo_controls prob_early_morning_sec, absorb( CourseByInstFE_1) vce(cluster id)
sum Icorrespond_Major1_college if BroadDef_730_sample_F18 == 1
est store m1

* gender
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 FemaleXIAssigned730 $demo_controls prob_early_morning_sec,  absorb(CourseByInstFE_1) vce(cluster id)
est store m2

* race
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 BlXIAssigned730 HispXIAssigned730 AsianXIAssigned730 OtherXIassigned730 $demo_controls prob_early_morning_sec, absorb(CourseByInstFE_1) vce(cluster id) 
est store m3

* sat scores
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 zSATxIAssigned730 $demo_controls prob_early_morning_sec,  absorb(CourseByInstFE_1) vce(cluster id)
est store m4

* 1st gen
reghdfe Icorrespond_Major1_college IFall2018AssignedBegin730 FirstGenXIAssigned730 $demo_controls prob_early_morning_sec,  absorb(CourseByInstFE_2) vce(cluster id)
est store m5

* regression table
esttab m1 m2 m3 m4 m5 using "${results}heter_effects_majorchoice_college_level.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace label



**** Table A.10: Effects on Different Outcomes for Domestic Students ****

** course grades - domestic students (Column 1 of Table A.10)
use "${cleandata}sample_course_grades_early_morning.dta",clear

* risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}

reghdfe CourseGPA IAssignedBegin730 $demo_controls prob_early_morning_sec if ICitizen ==1, absorb(TechByCourseByTerm) cluster(id)
sum CourseGPA if ICitizen ==1
est store m1

** STEM courses - domestic students (Column 2 of Table A.10)

* Call the data
use "${cleandata}subsample_stem_sample_early_morning.dta",clear

* risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}

* regression
reghdfe ICorrSTEM_LessEq2_END IAssignedBegin730 $demo_controls prob_early_morning_sec if corr_STEM_course_sample == 1 & ICitizen == 1, absorb(CourseByInstByTermFE) vce(cluster id)
sum ICorrSTEM_LessEq2_END if ICitizen == 1
est store m2

sum ICitizen if corr_STEM_course_sample == 1



** major choice and major earnings (Columns 3 and 4 of Table A.10)
use "${cleandata}subsample_major_early_morning.dta",clear

* risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}


* regression
rename IFall2018AssignedBegin730 IAssignedBegin730

reghdfe Icorrespond_Major1_college IAssignedBegin730 $demo_controls prob_early_morning_sec if BroadDef_730_sample_F18 == 1 & ICitizen == 1, absorb(CourseByInstFE_1) vce(cluster id)
est store m3
sum Icorrespond_Major1_college if BroadDef_730_sample_F18 == 1

reghdfe I_1stQuartile_earnings_major IAssignedBegin730 $demo_controls prob_early_morning_sec if BroadDef_730_sample_F18 == 1 & ICitizen == 1, absorb(CourseByInstFE_1) vce(cluster id)
sum I_1stQuartile_earnings_major if NarrowDef_730_sample_F21 == 1 & ICitizen == 1
est store m4
tab ICitizen if BroadDef_730_sample_F18 == 1
* Combine the regressions into the same table *
esttab m1 m2 m3 m4 using "${results}domesti_students_outcomes.tex", star(* 0.10 ** 0.05 *** 0.01) se r2 replace  label






**** Table A.11: Descriptive Statistics of the Field Survey ****

 Label demographic variables *

// Class
label variable IFreshman "Freshman"
label variable ISophomore "Sophomore"
label variable IJunior "Junior"
label variable ISenior "Senior"
label variable IGraduate "Graduate"
label variable IOther "Other"
// Gender
label variable IFemale "Female"
label variable IMale "Male"
label variable IPreferNoG "Gender-Not Disclosed"
// Race    
label variable IWhite "White"
label variable IBlack "Black"
label variable IAsian "Asian"
label variable IIslander "Islander"
label variable IPreferNoR "Race-Not Disclosed"
label variable IHispanic "Hispanic"
label variable INotHispanic "Non-Hispanic"
label variable IPreferNoH "Hispanic-Not Disclosed"
// Major
* GE/ Major/ Minor
tab Major1
label variable IGe "GE"
label variable IMajor "Major"
label variable IMinor "Minor"
* Business major/ Economics/ Other
tab Major2
label variable IBussMajor "Business (excl. Econ)"
label variable IEcon "Economics"
label variable IOtherMajor "Other Majors"
// Attendance
tab OftenAttend

label variable IAttend1 "1"
label variable IAttend2 "2"
label variable IAttend3 "3"
label variable IAttend3More "More than 3"


*** Initial Assignment (Columns 1 and 2 of Table A.11)

** Summary Stat (Initial Assignment - Early AM)**
sum IFreshman ISophomore IJunior ISenior IGraduate IOther IFemale IMale IPreferNoG IWhite IBlack IAsian IIslander IPreferNoR IHispanic INotHispanic IPreferNoH IGe IMajor IMinor IBussMajor IEcon IOtherMajor IAttend0 IAttend1 IAttend2 IAttend3 if InitialTime == "7:30 am - 8:20 am"

eststo domestic: estpost sum IFreshman ISophomore IJunior ISenior IGraduate IOther IFemale IMale IPreferNoG IWhite IBlack IAsian IIslander IPreferNoR IHispanic INotHispanic IPreferNoH IGe IMajor IMinor IBussMajor IEcon IOtherMajor IAttend0 IAttend1 IAttend2 IAttend3 IAttend3More if InitialTime == "7:30 am - 8:20 am"

esttab domestic using "${results}summary_statistics_initial_EarlyAM_student_survey.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label

** Summary Stat (Initial Assignment - Non-early AM)**
sum IFreshman ISophomore IJunior ISenior IGraduate IOther IFemale IMale IPreferNoG IWhite IBlack IAsian IIslander IPreferNoR IHispanic INotHispanic IPreferNoH IGe IMajor IMinor IBussMajor IEcon IOtherMajor IAttend0 IAttend1 IAttend2 IAttend3 if InitialTime == "9:30 am - 10:20 am"

eststo domestic: estpost sum IFreshman ISophomore IJunior ISenior IGraduate IOther IFemale IMale IPreferNoG IWhite IBlack IAsian IIslander IPreferNoR IHispanic INotHispanic IPreferNoH IGe IMajor IMinor IBussMajor IEcon IOtherMajor IAttend0 IAttend1 IAttend2 IAttend3 IAttend3More if InitialTime == "9:30 am - 10:20 am"

esttab domestic using "${results}summary_statistics_initial_NonEarlyAM_student_survey.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label


*** Actual Assignment (Columns 3, 4, 5 of Table A.11)

** Summary Stat (Actual Assignment - Early AM)**
sum IFreshman ISophomore IJunior ISenior IGraduate IOther IFemale IMale IPreferNoG IWhite IBlack IAsian IIslander IPreferNoR IHispanic INotHispanic IPreferNoH IGe IMajor IMinor IBussMajor IEcon IOtherMajor IAttend0 IAttend1 IAttend2 IAttend3 if ActualTime == "7:30 am - 8:20 am"

eststo domestic: estpost sum IFreshman ISophomore IJunior ISenior IGraduate IOther IFemale IMale IPreferNoG IWhite IBlack IAsian IIslander IPreferNoR IHispanic INotHispanic IPreferNoH IGe IMajor IMinor IBussMajor IEcon IOtherMajor IAttend0 IAttend1 IAttend2 IAttend3 IAttend3More if ActualTime == "7:30 am - 8:20 am"

esttab domestic using "${results}summary_statistics_actual_EarlyAM_student_survey.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label

** Summary Stat (Actual Assignment - Non-early AM)
sum IFreshman ISophomore IJunior ISenior IGraduate IOther IFemale IMale IPreferNoG IWhite IBlack IAsian IIslander IPreferNoR IHispanic INotHispanic IPreferNoH IGe IMajor IMinor IBussMajor IEcon IOtherMajor IAttend0 IAttend1 IAttend2 IAttend3 if ActualTime == "9:30 am - 10:20 am"

eststo domestic: estpost sum IFreshman ISophomore IJunior ISenior IGraduate IOther IFemale IMale IPreferNoG IWhite IBlack IAsian IIslander IPreferNoR IHispanic INotHispanic IPreferNoH IGe IMajor IMinor IBussMajor IEcon IOtherMajor IAttend0 IAttend1 IAttend2 IAttend3 IAttend3More if ActualTime == "9:30 am - 10:20 am"

esttab domestic using "${results}summary_statistics_actual_NonEarlyAM_student_survey.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label

** Summary Stat (Actual Assignment - Neither)
sum IFreshman ISophomore IJunior ISenior IGraduate IOther IFemale IMale IPreferNoG IWhite IBlack IAsian IIslander IPreferNoR IHispanic INotHispanic IPreferNoH IGe IMajor IMinor IBussMajor IEcon IOtherMajor IAttend0 IAttend1 IAttend2 IAttend3 if ActualTime == "Neither of them"

eststo domestic: estpost sum IFreshman ISophomore IJunior ISenior IGraduate IOther IFemale IMale IPreferNoG IWhite IBlack IAsian IIslander IPreferNoR IHispanic INotHispanic IPreferNoH IGe IMajor IMinor IBussMajor IEcon IOtherMajor IAttend0 IAttend1 IAttend2 IAttend3 IAttend3More if ActualTime == "Neither of them"

esttab domestic using "${results}summary_statistics_actual_neither_student_survey.tex", replace cell((mean(label(Mean)) sd(label(Std. Dev.)) min(label(Min.)) max(label(Max.)) count(label(N)))) nonumber nomtitle label




**** Table A.12: Effect of Assigned Early Morning Classes on Students' Class Experiences ****

* Call the data
use "${cleandata}student_survey_data_f22.dta",clear


** Strongly Agree

foreach x in SA Agree NA Disagree  {

* Q1
reg IEnjoyAttClass`x' IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store `x'_EnjoyAttClass
* Q2
reg IActPartInClass`x' IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store `x'_ActPartInClass
* Q3
reg IClassMatePartClass`x' IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store `x'_ClassMatePartClass
* Q4
reg ICriticalThinking`x' IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store `x'_CriticalThinking
* Q5
reg IMotivateLearning`x' IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store `x'_MotivateLearning
* Q6
reg ILearnMoreDiffSec`x' IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store `x'_LearnMoreDiffSec
* Q7
reg IWannaTakeAnotherEcon`x' IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store `x'_TakeAnotherEcon
* Q8
reg IClearLec_ins`x' IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store `x'_ClearLec_ins
* Q9
reg IEngagingLec_ins`x' IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store `x'_EngagingLec_ins
* Q10
reg IHelpMeLearn_ins`x' IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store `x'_HelpMeLearn_ins
* Q11
reg IEnthusiastic_inc`x' IAssigned730 i.Class IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor, robust
est store `x'_Enthusiastic_inc

* Construct the table
esttab `x'_EnjoyAttClass `x'_ActPartInClass `x'_ClassMatePartClass `x'_CriticalThinking `x'_MotivateLearning `x'_LearnMoreDiffSec `x'_TakeAnotherEcon `x'_ClearLec_ins `x'_EngagingLec_ins `x'_HelpMeLearn_ins `x'_Enthusiastic_inc using "${results}`x'_StudentSurvey_OLS.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace label

}


**** Table A.13: Effect of Assigned Early Morning Classes on Freshman Students' Class Experiences ****

* Call the data
use "${cleandata}student_survey_data_f22.dta",clear

** Freshman Respondents 
** Focus on Strongly "Agree" and "Agree" in each question
* Q1
reg IEnjoyAttClassAgreeAb IAssigned730 IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor if Class == 1, robust 
est store s2_EnjoyAttClass
sum IEnjoyAttClassAgreeAb if Class == 1

* Q2
reg IActPartInClassAgreeAb IAssigned730 IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor if Class == 1, robust
est store s2_ActPartInClass
sum IActPartInClassAgreeAb if Class == 1

* Q3
reg IClassMatePartClassAgreeAb IAssigned730 IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor if Class == 1, robust
est store s2_ClassMatePartClass
sum IClassMatePartClassAgreeAb if Class == 1

* Q4
reg ICriticalThinkingAgreeAb IAssigned730 IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor if Class == 1, robust
est store s2_CriticalThinking
sum ICriticalThinkingAgreeAb if Class == 1

* Q5
reg IMotivateLearningAgreeAb IAssigned730 IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor if Class == 1, robust
est store s2_MotivateLearning
sum IMotivateLearningAgreeAb if Class == 1

* Q6
reg ILearnMoreDiffSecAgreeAb IAssigned730 IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor if Class == 1, robust
est store s2_LearnMoreDiffSec
sum ILearnMoreDiffSecAgreeAb if Class == 1

* Q7
reg IWannaTakeAnotherEconAgreeAb IAssigned730 IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor if Class == 1, robust
est store s2_TakeAnotherEcon
sum IWannaTakeAnotherEconAgreeAb if Class == 1

* Q8
reg IClearLec_insAgreeAb IAssigned730 IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor if Class == 1, robust
est store s2_ClearLec_ins
sum IClearLec_insAgreeAb if Class == 1

* Q9
reg IEngagingLec_insAgreeAb IAssigned730 IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor if Class == 1, robust
est store s2_EngagingLec_ins
sum IEngagingLec_insAgreeAb if Class == 1

* Q10
reg IHelpMeLearn_insAgreeAb IAssigned730 IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor if Class == 1, robust
est store s2_HelpMeLearn_ins
sum IHelpMeLearn_insAgreeAb if Class == 1

* Q11
reg IEnthusiastic_incAgreeAb IAssigned730 IFemale IMale IPreferNoG IHispanic INotHispanic IPreferNoH IAsian IBlack IIslander IWhite IPreferNoR IGe IMajor IMinor IBussMajor IEcon IOtherMajor if Class == 1, robust
est store s2_Enthusiastic_inc
sum IEnthusiastic_incAgreeAb if Class == 1

* Construct the table
esttab s2_EnjoyAttClass s2_ActPartInClass s2_ClassMatePartClass s2_CriticalThinking s2_MotivateLearning s2_LearnMoreDiffSec s2_TakeAnotherEcon s2_ClearLec_ins s2_EngagingLec_ins s2_HelpMeLearn_ins s2_Enthusiastic_inc using "${results}SA_and_A_StudentSurvey_OLS_Freshman.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace label


** Dependent variable mean
sum IEnjoyAttClassAgree IActPartInClassAgree IClassMatePartClassAgree ICriticalThinkingAgree IMotivateLearningAgree ILearnMoreDiffSecAgree IWannaTakeAnotherEconAgree IClearLec_insAgree IEngagingLec_insAgree IHelpMeLearn_insAgree IEnthusiastic_incAgree





**** Table A.14: Effect on Getting Different Grades ****

* Call the data 
use "${cleandata}sample_course_grades_early_morning.dta",clear

* Effects on grades - discrete measure from A to D- (appendix table)

* IGreaterA  (Column 1 of Table A.14)
reghdfe IGreaterA IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) vce(cluster  id)
sum IGreaterA
est store m4_IGreaterA

* IGreaterAMinus  (Column 2 of Table A.14)
reghdfe IGreaterAMinus IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) vce(cluster  id) 
sum IGreaterAMinus
est store m4_IGreaterAMinus

* IGreaterBPlus  (Column 3 of Table A.14)
reghdfe IGreaterBPlus IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) vce(cluster  id) 
sum IGreaterBPlus
est store m4_IGreaterBPlus

* IGreaterB  (Column 4 of Table A.14) 
reghdfe IGreaterB IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) vce(cluster  id) 
sum IGreaterB
est store m4_IGreaterB

*IGreaterBMinus  (Column 5 of Table A.14)
reghdfe IGreaterBMinus IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) vce(cluster  id) 
sum IGreaterBMinus
est store m4_IGreaterBMinus

* IGreaterCPlus  (Column 6 of Table A.14)
reghdfe IGreaterCPlus IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) vce(cluster  id) 
sum IGreaterCPlus
est store m4_IGreaterCPlus

* IGreaterC  (Column 7 of Table A.14)
reghdfe IGreaterCPlus IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) vce(cluster  id) 
sum IGreaterC
est store m4_IGreaterC

* IGreaterCMinus  (Column 8 of Table A.14)
reghdfe IGreaterCMinus IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) vce(cluster  id) 
sum IGreaterCMinus
est store m4_IGreaterCMinus

* IGreaterDPlus  (Column 9 of Table A.14)
reghdfe IGreaterDPlus IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) vce(cluster  id) 
sum IGreaterDPlus
est store m4_IGreaterDPlus

* IGreaterD  (Column 10 of Table A.14)
reghdfe IGreaterD IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) vce(cluster  id)
sum IGreaterD
est store m4_IGreaterD

* IGreaterDMinus (Column 11 of Table A.14)
reghdfe IGreaterDMinus IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) vce(cluster id) 
sum IGreaterDMinus
est store m4_IGreaterDMinus


* Construct the tables
esttab m4_IGreaterA m4_IGreaterAMinus m4_IGreaterBPlus m4_IGreaterB m4_IGreaterBMinus m4_IGreaterCPlus m4_IGreaterC m4_IGreaterCMinus m4_IGreaterDPlus m4_IGreaterD m4_IGreaterDMinus using "${results}discrete_course_grade_results_ols.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace label



**** Table A.15: List of Selective Majors in the Sample ****
/*
Not applicable

*/

**** Table A.16: List of Courses with Direct Follow-Up Courses in the Study ****
/*
Not applicable

*/

**** Table A.17: Effect on Sequential Course Grades ****
* call the main data
use "${cleandata}sample_course_grades_early_morning.dta",clear

* merge the data
merge m:1 id course using "${cleandata}future_course_grades_for_fall2018.dta",gen(merge_1) keep(1 3)
merge m:1 id course using "${cleandata}future_course_grades_for_fall2019.dta",gen(merge_2) keep(1 3)


* risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}


** Panel 2: Reduced Form Estimates
* col 3
reghdfe future_course_grade IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) cluster(id)
est store m3
keep if e(sample) == 1

* col 1
reghdfe future_course_grade IAssignedBegin730, absorb() cluster(id)
est store m1

* col 2
reghdfe future_course_grade IAssignedBegin730 $demo_controls, absorb(TechByCourseByTerm) cluster(id)
est store m2

** Panel 1: 2SLS Estimates
encode TechByCourseByTerm, gen(TechByCourseByTerm_encoded)

* col 1
ivreghdfe future_course_grade  (IEndBegin730 = IAssignedBegin730), cluster(id)
est store m1

* col 2
ivreghdfe future_course_grade i.TechByCourseByTerm_encoded $demo_controls (IEndBegin730 = IAssignedBegin730), cluster(id)
est store m2

* col 3
ivreghdfe future_course_grade i.TechByCourseByTerm_encoded $demo_controls prob_early_morning_sec (IEndBegin730 = IAssignedBegin730), cluster(id)
est store m3

* regression table
esttab m1 m2 m3 using "${results}effect_on_future_coruse_greade_results_2sls.tex", star(* 0.10 ** 0.05 *** 0.01) se r2 replace label






* output the regression table
esttab m1 m2 m3 using "${results}effect_on_future_coruse_greade_results_ols.tex", star(* 0.10 ** 0.05 *** 0.01) se r2 replace label







**** Table A.18: Effect on Leave-One-Out Term GPA ****

* Call the data
use "${cleandata}sample_course_grades_early_morning.dta",clear


* take out the courses in the loo calculation
forvalues i = 1/19 {
	replace credits`i' = 0 if course`i' == course
	replace grade`i' = 0 if course`i' == course
	replace course`i' = "" if course`i' == course
}

* replace missing credits, grades as 0s
forvalues i = 1/19 {
	replace credits`i' = 0 if credits`i' == .
	replace grade`i' = 0 if grade`i' == .
}

// risk sets method - new (updated on 2/11/2025)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_201910.dta",gen(sim_assigned_time_201910)
merge m:1 Academic_Period id course using "${cleandata}sim_assigned_time_202010.dta",gen(sim_assigned_time_202010)

forvalues i =0/11 {
	gen I_prob_em_bin_`i' = I_prob_em_bin_`i'_201910 if Academic_Period == 201910 
	replace I_prob_em_bin_`i' = I_prob_em_bin_`i'_202010 if Academic_Period == 202010
}

gen prob_early_morning_sec = prob_early_morning_sec_201910 if Academic_Period == 201910
replace prob_early_morning_sec = prob_early_morning_sec_202010 if Academic_Period == 202010

forvalues i = 0/11 {
	replace I_prob_em_bin_`i' = 0 if I_prob_em_bin_`i'==.
	replace prob_early_morning_sec = 0 if prob_early_morning_sec ==.
}


// Panel 1: 2SLS Estimates
eststo clear
encode TechByCourseByTerm, gen(TechByCourseByTerm_encoded)

* col 1
ivreghdfe loo_gpa (IEndBegin730 = IAssignedBegin730), cluster(id)
est store m1

* col 2
ivreghdfe loo_gpa (IEndBegin730 = IAssignedBegin730) $demo_controls i.TechByCourseByTerm_encoded, cluster(id)
est store m2

* col 3
ivreghdfe loo_gpa (IEndBegin730 = IAssignedBegin730) $demo_controls prob_early_morning_sec i.TechByCourseByTerm_encoded, cluster(id)
est store m3

* regression table
esttab m1 m2 m3 using "${results}loo_grade_results_2sls.tex", star(* 0.10 ** 0.05 *** 0.01) se r2 replace label

// Panel 2: Reduced Form Estimates

* col 1
reghdfe loo_gpa IAssignedBegin730, absorb() cluster(id) 
est store m1

* col 2
reghdfe loo_gpa IAssignedBegin730 $demo_controls, absorb(TechByCourseByTerm) cluster(id) 
est store m2

* col 3
reghdfe loo_gpa IAssignedBegin730 $demo_controls prob_early_morning_sec, absorb(TechByCourseByTerm) cluster(id) 
est store m3

* regression table
esttab m1 m2 m3 using "${results}loo_grade_results_ols.tex" , star(* 0.10 ** 0.05 *** 0.01) se r2 replace label


*------------------------------------------------------------------------------*


















